<script setup>
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
const props = defineProps(['name'])
const option =  ref({
    tooltip: {
      trigger: 'item'
    },
    title: {
      text: '200',
      subtext: '共发布活动',
      left: 'center',
      top: '40%',
      show: true,
      textStyle: {
        fontSize: 12,
        color: 'black',
        align: 'center'
      },
      subtextStyle: {
        fontFamily: '微软雅黑',
        fontSize: 14,
        color: 'black'
      }
    },
    series: [
      {
        name: 'Access From',
        type: 'pie',
        radius: ['40%', '70%'],
        avoidLabelOverlap: false,
        itemStyle: {
          borderRadius: 10,
          borderColor: '#fff',
          borderWidth: 2
        },
        emphasis: {
          label: {
            show: true,
            fontSize: 40,
            fontWeight: 'bold'
          }
        },
        data: [
          { value: 1048, name: 'Search Engine' },
          { value: 735, name: 'Direct' },
          { value: 580, name: 'Email' },
          { value: 484, name: 'Union Ads' },
          { value: 300, name: 'Video Ads' }
        ]
      }
    ]
  })

onMounted(() => {
  const myChart = echarts.init(document.getElementById('charts_' + props.name))
  myChart.setOption(option.value)
  window.addEventListener('resize', () => {
    myChart.resize()
  })
})
</script>

<template>
<div :id="'charts_' + props.name" style="width: 50%;height: 100%;"></div>
</template>

<style scoped lang='less'>
</style>